﻿using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Linq;
using System.Web;
using Microsoft.AspNetCore.Mvc;
using YiSha.Util;
using YiSha.Util.Model;
using YiSha.Entity;
using YiSha.Model;
using YiSha.Admin.Web.Controllers;
using YiSha.Entity.QixingManage;
using YiSha.Business.QixingManage;
using YiSha.Model.Param.QixingManage;

namespace YiSha.Admin.Web.Areas.QixingManage.Controllers
{
    /// <summary>
    /// 创 建：admin
    /// 日 期：2024-04-17 00:19
    /// 描 述：商务合作控制器类
    /// </summary>
    [Area("QixingManage")]
    public class PartnersController :  BaseController
    {
        private PartnersBLL partnersBLL = new PartnersBLL();

        #region 视图功能
        [AuthorizeFilter("qixing:partners:view")]
        public ActionResult PartnersIndex()
        {
            return View();
        }

        public ActionResult PartnersForm()
        {
            return View();
        }
        #endregion

        #region 获取数据
        [HttpGet]
        [AuthorizeFilter("qixing:partners:search")]
        public async Task<ActionResult> GetListJson(PartnersListParam param)
        {
            TData<List<PartnersEntity>> obj = await partnersBLL.GetList(param);
            return Json(obj);
        }

        [HttpGet]
        [AuthorizeFilter("qixing:partners:search")]
        public async Task<ActionResult> GetPageListJson(PartnersListParam param, Pagination pagination)
        {
            TData<List<PartnersEntity>> obj = await partnersBLL.GetPageList(param, pagination);
            return Json(obj);
        }

        [HttpGet]
        public async Task<ActionResult> GetFormJson(long id)
        {
            TData<PartnersEntity> obj = await partnersBLL.GetEntity(id);
            return Json(obj);
        }
        #endregion

        #region 提交数据
        [HttpPost]
        [AuthorizeFilter("qixing:partners:add,qixing:partners:edit")]
        public async Task<ActionResult> SaveFormJson(PartnersEntity entity)
        {
            TData<string> obj = await partnersBLL.SaveForm(entity);
            return Json(obj);
        }

        [HttpPost]
        [AuthorizeFilter("qixing:partners:delete")]
        public async Task<ActionResult> DeleteFormJson(string ids)
        {
            TData obj = await partnersBLL.DeleteForm(ids);
            return Json(obj);
        }
        #endregion
    }
}
